<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑战法</title>
</head>
<body>
<script type="text/html" id="form">
    <input type="hidden" name="id" value="{{ d.id }}" />
    <div class="mainBox">
        <div class="main-container">
            <blockquote class="layui-elem-quote">基础信息</blockquote>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" value="{{d.name}}" lay-verify="required" autocomplete="off" placeholder="请输入战法名称"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <text style="color:red;">图片尺寸建议 1:1比例</text>
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法图示</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="icon"
                         data-dir="xm_game/sgz/war_methods/icon"
                         data-accept="image"
                         data-type="ali-oss"
                         data-layVerify="required"
                         data-showChoiceBtn="false"
                         data-uploaded="{{d.icon}}"
                         data-uploadedId="{{d.icon}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <text style="color:red;">图片尺寸建议 360*490比例</text>
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法大图</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="picture"
                         data-dir="xm_game/sgz/war_methods/picture"
                         data-accept="image"
                         data-type="ali-oss"
                         data-layVerify="required"
                         data-showChoiceBtn="false"
                         data-uploaded="{{d.picture}}"
                         data-uploadedId="{{d.picture}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法类型</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="category"
                         data-sourceType="route"
                         data-source="/admin.sgz.war_methods/getCategory"
                         data-sourceTree="false"
                         data-paging="true"
                         data-valueField="category"
                         data-textField="category"
                         data-radio="true"
                         data-placeholder="请选择战法类型"
                         data-selected="{{d.category}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法品质</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="level"
                         data-sourceType="data"
                         data-source="[{name:'S',value:'S'},{name:'A',value:'A'},{name:'B',value:'B'}]"
                         data-radio="true"
                         data-placeholder="请选择战法品质"
                         data-selected="{{d.level}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法来源</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="form"
                         data-sourceType="data"
                         data-source="[{name:'自带战法',value:'1'},{name:'传承战法',value:'2'},{name:'事件战法',value:'3'}]"
                         data-radio="true"
                         data-placeholder="请选择战法来源"
                         data-selected="{{d.form}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    适用兵种</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="arms"
                         data-sourceType="route"
                         data-source="/admin.sgz.war_methods/getArms"
                         data-sourceTree="false"
                         data-paging="true"
                         data-valueField="arm"
                         data-textField="arm"
                         data-placeholder="请选择适用兵种"
                         data-selected="{{d.arms}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" title="自带武将">自带武将</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="generals_one"
                         data-sourceType="route"
                         data-source="/admin.sgz.generals/index"
                         data-sourceTree="false"
                         data-paging="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择自带武将"
                         data-selected="{{d.generals_one}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" title="传承武将">传承武将</label>
                <div class="layui-input-inline">
                    <div class="xmSelect"
                         data-name="generals_two"
                         data-sourceType="route"
                         data-source="/admin.sgz.generals/index"
                         data-sourceTree="false"
                         data-paging="true"
                         data-valueField="id"
                         data-textField="name"
                         data-placeholder="请选择传承武将"
                         data-selected="{{d.generals_two}}"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    效果冲突</label>
                <div class="layui-input-block">
                    <input type="text" name="effect_conflict" value="{{d.effect_conflict}}" lay-verify="required" autocomplete="off"
                           placeholder="请输入效果冲突"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    战法效果</label>
                <div class="layui-input-block">
                    <input type="text" name="methods_effect" value="{{d.methods_effect}}" lay-verify="required" autocomplete="off"
                           placeholder="请输入战法效果"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    发动目标</label>
                <div class="layui-input-block">
                    <input type="text" name="methods_target" value="{{d.methods_target}}" lay-verify="required" autocomplete="off"
                           placeholder="请输入发动目标"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    发动概率</label>
                <div class="layui-input-block">
                    <input type="text" name="launch_probability" value="{{d.launch_probability}}" lay-verify="required" autocomplete="off"
                           placeholder="请输入发动概率"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">
                    <text style="color:red;">*</text>
                    战法说明</label>
                <div class="layui-input-block">
                        <textarea placeholder="请输入战法说明"  name="methods_description" class="layui-textarea"
                                  lay-verify="required">{{d.methods_description}}</textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="laytp-form">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form">
</form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    layui.use(['laytp'],function(){
        let form = layui.form;
        let $ = layui.jquery;
        //获取参数ID
        var id = facade.getUrlParam('id');
        if(!id){
            facade.error('参数ID不能为空');
            return false;
        }

        //获取数据，渲染到对应的节点上
        facade.ajax({
            route: "/admin.sgz.war_methods/info",
            data: {id: id},
            successAlert: false,
            showLoading: true
        }).done(function(res){
            if(res.code === 0){
                layui.laytpl($("#form").html()).render(res.data,function(string){
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });
            }
        });

        form.on('submit(laytp-form)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.sgz.war_methods/edit',
                data:data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>